package cn.com.suiyi.shixingshengxian.base;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/7/18.
 */



public abstract class MVPActivity< V, P extends IBasePresenter<V>> extends BaseActivity {
    private P presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        presenter = getPresenter();
        presenter.attachView((V)this);
        super.onCreate(savedInstanceState);

    }

    /**
     * 获取presenter
     *
     * @return
     */
    public abstract P getPresenter();
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (presenter != null) {
            presenter.detachView();
            presenter = null;
        }
    }
}
